<?php

class Social_Controller_Browse_Linkedin_Auth
{

	function execute($request)
	{
		$adapter = Nuo::getObject('social/adapter/linkedin');

		$clientApi = $adapter -> getClientApi();

		// send a request for a LinkedIn access token
		$response = $clientApi -> retrieveTokenRequest();
		
		if ($response['success'] === TRUE)
		{
			// store the request token
			$_SESSION['oauth']['linkedin']['request'] = $response['linkedin'];

			// redirect the user to the LinkedIn authentication/authorisation
			// page to initiate validation.
			header('Location: ' . LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
		}
		else
		{
			// bad token request
			echo "Request token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($clientApi, TRUE) . "</pre>";
		}
	}

}
